package com.suemi.rpc.entity;

import java.util.HashMap;
import java.util.Map;

public enum MessageType {
  ;

  private final static Map<MessageType, Class<?>> clazzMap = new HashMap<>();

  private byte value;

  MessageType(byte value) {
    this.value = value;
  }

  public static MessageType from(byte value) {
    for (MessageType type : MessageType.values())
      if (type.value == value) return type;
    throw new IllegalArgumentException("invalid message type!");
  }

  public byte value() {
    return this.value;
  }

  public Class<?> messageClass() {
    return clazzMap.get(this);
  }
}
